package com.css.fxfzxczh.modules.disasterSituationDataManage.baseDataManage.controller;

import com.alibaba.fastjson.JSONObject;
import com.css.fxfzxczh.base.response.RestResponse;
import com.css.fxfzxczh.modules.disasterSituationDataManage.baseDataManage.param.QueryByVersionParam;
import com.css.fxfzxczh.modules.disasterSituationDataManage.baseDataManage.param.SysDataVersionPageParam;
import com.css.fxfzxczh.modules.disasterSituationDataManage.baseDataManage.service.BasDatManageService;
import com.css.fxfzxczh.modules.disasterSituationDataManage.baseDataManage.vo.SysDataVersionPageVo;
import com.css.fxfzxczh.util.PlatformPageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @Author: xzy
 * @CreateTime: 2023/08/2
 * @Description: 基础数据管理
 */
@RestController
@RequestMapping("/basDatManage")
@Slf4j
public class BasDatManageController {
    @Resource
    BasDatManageService basDatManageService;

    /**
     * 获取菜单列表
     *
     * @return
     */
    @GetMapping("/getMenuList")
    public RestResponse getMenuList() {
        RestResponse restResponse = null;
        try {
            List<Map<String,Object>> list = basDatManageService.getMenuList();
            restResponse = RestResponse.succeed(list);
        } catch (Exception e) {
            String errormessage = "查询失败";
            log.error(errormessage, e);
            restResponse = RestResponse.fail(errormessage);
        }
        return restResponse;
    }

    /**
     * 获取版本列表
     *
     * @return
     */
    @GetMapping("/getVersionList")
    public RestResponse getVersionList(SysDataVersionPageParam param) {
        RestResponse restResponse = null;
        try {
            List<SysDataVersionPageVo> list = basDatManageService.getVersionList(param);
            restResponse = RestResponse.succeed(list);
        } catch (Exception e) {
            String errormessage = "查询失败";
            log.error(errormessage, e);
            restResponse = RestResponse.fail(errormessage);
        }
        return restResponse;
    }

    /**
     * 获取版本列表
     *
     * @return
     */
    @GetMapping("/getListAndGeom")
    public RestResponse getListAndGeom(QueryByVersionParam param, HttpServletRequest request) {
        RestResponse restResponse = null;
        try {
            int curPage = Integer.parseInt(request.getParameter(PlatformPageUtils.CUR_PAGE));
            int pageSize = Integer.parseInt(request.getParameter(PlatformPageUtils.PAGE_SIZE));
            Map<String,Object> list = basDatManageService.getListAndGeom(param,curPage,pageSize);
            restResponse = RestResponse.succeed(list);
        } catch (Exception e) {
            String errormessage = "查询失败";
            log.error(errormessage, e);
            restResponse = RestResponse.fail(errormessage);
        }
        return restResponse;
    }

}
